<template lang="html">
  <section class="components-orders_order_list" v-if="orderList">
    <template v-if="orderList.length > 0">
      <div class="lessonDefault "  v-for="item in orderList" @click="goToDetail(item)">
        <div class="lesson_art">
          <h2>{{item.subjectName}}</h2>
          <p class="lesson_art_teacher">{{item.coachName}}</p>
          <p class="lesson__art_add">{{item.address}}</p>
          <p>{{item.showTime}}</p>
        </div>
        <div class="lesson_btn">
          <button>查看详情</button>
        </div>
        <div class="lesson_remain" :class="status">
          <span>{{tag}}</span>
          <div class="remainTri"></div>
          <div class="remainTriRight"></div>
        </div>
      </div>
      <Loadmore v-show="canLoadMore" v-on:loadmore="$emit('loadmore')"></Loadmore>
    </template>
    <template v-else>
      <h1 class="order_list-none">该分类下暂无课程</h1>
    </template>
  </section>
</template>

<script>
const STATUS_TO_TAG = {
  remain: '待上课',
  finish: '完成',
  cancel: '退课',
}
export default {
  props: {
    orderList: {
      type: Array,
      required: true
    },
    status: {
      type: String,
      required: true
    },
    canLoadMore: {
      type: Number,
      required: true
    }
  },
  components: {
    Loadmore: require('@/components/common_loadmore')
  },
  computed: {
    tag(){
      return STATUS_TO_TAG[this.status]
    }
  },
  methods: {
    goToDetail(detail){
      this.$emit('onClickItem', detail)
    }
  }
}
</script>

<style lang="scss" scoped>
@import "../css/config";
.components-orders_order_list{
  width: 100%;
  box-sizing: border-box;
  padding-bottom: 30px;
  background-color: transparent;
  $divborder:15px;
  .order_list-none{
    display: block;
    width: 100%;
    line-height: 3;
    text-align: center;
    font-size: 35px;
    color: #fff;
  }
  .lessonDefault{
    width: 697px;
    box-sizing: border-box;
    padding: 0 30px 0 37px;
    background:#fff ;
    margin-bottom: 32px;
    border-radius: $divborder;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    &:active{
       background: #e2e2e2;
    }
    .lesson_art{
      margin-left: 18px;
      width: 450px;
      box-sizing: border-box;
      padding: 28px 0 24px 0;
      display: flex;
      flex-direction: column;
      justify-content:space-between;
      p{
        font-size: 25.01px;
        color: #575757;
        margin-top: 15px;
      }
      h2{
        font-size: 33.35px;
        font-weight: bolder;

      }
      .lesson_art_teacher{
        font-weight: bolder;
        color: #000;
        margin-top: 20px;
      }
      .lesson__art_add{
        font-size: 20.83px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }
    .lesson_btn{
      flex:1;
      text-align: right;
      button{
        width: 138px;
        height: 60px;
        font-size: 25px;
        letter-spacing: 1px;
        color: #000;
        border: 2px solid  #000;
        border-radius: $divborder;
      }
    }
    .lesson_remain{
      color: #fff;
      padding: 10px 5px 5px;
      width: 72px;
      text-align: center;
      font-size: 20.83px;
      position: absolute;
      right: 55px;
      top: 0;
      background: $common-red;
      &.remain{
        background: $common-red;
        .remainTri{
          border-top: 28px solid $common-red;
        }
        .remainTriRight{
          border-top: 28px solid $common-red;
        }
      }
      &.finish{
        color: #000;
        background: #e0ff6a;
        .remainTri{
          border-top: 28px solid #e0ff6a;
        }
        .remainTriRight{
          border-top: 28px solid #e0ff6a;
        }
      }
      &.cancel{
        background: #a9a9a9;
        .remainTri{
          border-top: 28px solid #a9a9a9;
        }
        .remainTriRight{
          border-top: 28px solid #a9a9a9;
        }
      }
      .remainTri{
        position: absolute;
        bottom: -25px;
        left: 0;
        width: 0;
        height: 0;
        border-left: 0 solid transparent;
        border-right: 50px solid transparent;
        border-top: 28px solid $common-red;
      }
      .remainTriRight{
        position: absolute;
        bottom: -25px;
        right: 0;
        width: 0;
        height: 0;
        border-left: 50px solid transparent;
        border-right: 0 solid transparent;
        border-top: 28px solid $common-red;
      }
    }
  }
}
</style>
